package com.changhong.yutong.common.utils;

import com.changhong.yutong.common.constant.ResultEnum;

/**
 * Created by Administrator on 2018/4/2
 */
public class ResultVoUtils {

    public static <T> ResultVo<T> success(T t) {
        ResultVo<T> resultVo = new ResultVo<>();
        resultVo.setCode(ResultEnum.SUCCESS.getCode());
        resultVo.setMsg(ResultEnum.SUCCESS.getMsg());
        resultVo.setData(t);
        return resultVo;
    }

    public static ResultVo<Object> success() {
        return success(null);
    }

    public static ResultVo error(Integer code, String msg) {
        ResultVo resultVo = new ResultVo();
        resultVo.setCode(code);
        resultVo.setMsg(msg);
        return resultVo;
    }

    public static ResultVo error(ResultEnum resultEnum) {
        return ResultVoUtils.error(resultEnum.getCode(), resultEnum.getMsg());
    }

    public static ResultVo errorSystem(String msg) {
        return error(ResultEnum.SYSTEM_ERROR.getCode(), msg);
    }
}
